{* $Id$ *}
{include_core file="admin/lib/header.html" title="商品销售数据"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">商品销售数据<span>查看各品类指定时间内的出货量、销售额</span></h2>
</div>
<div class="search-form">
    <form action="{AnUrl('records_center/admin/goods')}" method="get">
        {if !isset($search_filter)}
        {$search_filter = URLTracker::val('search_filter')}
        {/if}
        <div id="basis_type" class="search-form-tabs clearfix">
            <input class="search-form-tabs-current-index" type="hidden" value="{$search_filter.basis_type}" name="search_filter[basis_type]">
            <ul>
                <li{if $search_filter.basis_type==0} class="ui-tabs-selected"{/if}><a href="#category-tab" >品类</a></li>
                <li{if $search_filter.basis_type==1} class="ui-tabs-selected"{/if}><a href="#goods-tab" >卖品</a></li>
            </ul>
            <div id="category-tab" class="ui-tabs-hide">
                <div class="search-f-map">
                    <label class="label label-default"><input class="select-all" type="checkbox">全选</label>
                    {if !isset($CATEGORY_LIST)}
                    {$CATEGORY_LIST = goods_config::goods_category()}
                    {/if}
                    {foreach $CATEGORY_LIST as $code => $item}
                    <label class="label label-normal"><input value="{$code}" name="search_filter[category_id][]" type="checkbox"
                                                             {if in_array($code, $search_filter.category_id)}
                                                             checked="checked" {/if}>{$item.title}</label>
                    {/foreach}
                </div>
            </div>
            <div id="goods-tab" style="padding-bottom: 5px;">
                {foreach $CATEGORY_GOODS_TREE as $cat_id => $cat}
                <fieldset>
                    <legend>{$cat.title}</legend>
                    <div class="search-f-map">
                        <label class="label label-default"><input class="select-all" type="checkbox">全选</label>
                        {foreach $cat.goods_list as $goods_id => $goods}
                        <label class="label label-normal"><input value="{$goods_id}" name="search_filter[goods_id][]" type="checkbox"
                                                                 {if in_array($goods_id, $search_filter.goods_id)}
                                                                 checked="checked" {/if}>{$goods.title}</label>
                        {/foreach}
                    </div>
                </fieldset>
                {/foreach}


                {*<div class="search-f-map" class="ui-tabs-hide">
                    {if !isset($GOODS_LIST)}
                    {$GOODS_LIST = goods_config::goods_list()}
                    {/if}
                    {foreach $GOODS_LIST as $code => $item}
                    <label class="label label-normal"><input value="{$code}" name="search_filter[goods_id][]" type="checkbox"
                                                             {if in_array($code, $search_filter.goods_id)}
                                                             checked="checked" {/if}>{$item.title}</label>
                    {/foreach}
                </div>*}
            </div>
        </div>
        <div id="filter_type" class="search-form-tabs">
            <input class="search-form-tabs-current-index" type="hidden" value="{$search_filter.filter_type}" name="search_filter[filter_type]">
            <ul>
                <li{if $search_filter.filter_type==0} class="ui-tabs-selected"{/if}><a href="#province-tab">地区</a></li>
                <li{if $search_filter.filter_type==1} class="ui-tabs-selected"{/if}><a href="#agency-tab">合伙人</a></li>
            </ul>
            <div id="province-tab" class="ui-tabs-hide">
                <div class="search-f-map search-f-map-province">
                    <!-- <label class="label"><input class="select-all" type="checkbox">全选</label> -->
                    {if !isset($PROVINCE_INDEX)}
                    {$PROVINCE_INDEX = area_helper::province_index()}
                    {/if}
                    {foreach $PROVINCE_INDEX as $code => $item}
                    <label class="label label-normal"><input value="{$code}" name="search_filter[province_id][]" type="checkbox"
                                                             {if in_array($code, $search_filter.province_id)}
                                                             checked="checked" {/if}>{$item.shortname}</label>
                    {/foreach}
                </div>
                <label style="line-height: 2em">
                    <input name="search_filter[perspective_agency]"{if $search_filter.perspective_agency == 1} checked="checked"{/if} type="checkbox" value="1" style="margin-right: 5px;">透视到合伙人
                </label>
            </div>
            <div id="agency-tab" class="ui-tabs-hide" style="padding-bottom: 5px;">
                <div>
                    {$agency_id = URLTracker::val('search_filter', 'agency_id')}
                    {if !isset($AGENCY_LIST)}
                    {$AGENCY_LIST = user_helper::get_all_dealers_info()}
                    {/if}
                    {foreach $agency_id as $aid}
                    <select placeholder="请选择合伙人" class="add-f-ipt1" id="suggest_agency" name="search_filter[agency_id][]">
                        <option value="0" {if $aid== 0} selected="selected" {/if}>请选择合伙人</option>
                        {foreach $AGENCY_LIST as $k => $v}
                        <option value="{$v.id}" {if $v.id== $aid} selected="selected" {/if}>{$v.realname}({$v.mobile})</option>
                        {/foreach}
                    </select>
                    {foreachelse}
                    <select placeholder="请选择合伙人" class="add-f-ipt1" id="suggest_agency" name="search_filter[agency_id][]">
                        <option value="0" selected="selected">请选择合伙人</option>
                        {foreach $AGENCY_LIST as $k => $v}
                        <option value="{$v.id}">{$v.realname}({$v.mobile})</option>
                        {/foreach}
                    </select>
                    {/foreach}
                </div>
            </div>
        </div>
        <p class="js-time-range-check">
            <label for="" class="search-f-label">时间：</label>
            <input type="text" class="search-f-ipt1 search-f-ipt2 js-date-picker js-start-time"
                   name="search_filter[start_date]"
                   value="{URLTracker::val('search_filter', 'start_date')}">
            <span class="search-f-line"></span>
            <input type="text" class="search-f-ipt1 search-f-ipt2 js-date-picker js-end-time"
                   name="search_filter[end_date]"
                   value="{URLTracker::val('search_filter', 'end_date')}">
        </p>
        <p>
            <label for="" class="search-f-label"></label>
            <button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button>
        </p>
    </form>
</div>
<!--start:列表-->
<table class="list-table list-table-sort">
    <thead>
    <tr>
        {foreach $table_column_title as $title}
        {if is_array($title)}
        <th{if isset($title[1]) && $title[1]==0} class="no-sort"{/if}{if isset($title[2])} data-sort-type="{$title[2]}"{/if}>{$title[0]}</th>
        {else}
        <th class="no-sort">{$title}</th>
        {/if}
        {/foreach}
    </tr>
    </thead>
    <tbody>
    {foreach $data as $k => $v}
    <tr>
        {foreach $table_column as $column}
        <td>{$v[$column]}</td>
        {/foreach}
    </tr>
    {foreachelse}
    <tr>
        <td class="txtleft" colspan="3">暂无数据</td>
    </tr>
    {/foreach}
    </tbody>
</table>
<!--end:列表-->
{load_js file="module/search_f_map.js"}
{include_core file="module/search_form_tabs.html"}
{include_core file="module/suggestion.html" id="suggest_agency"}
{include_core file="module/search_form_check.html"}
{include_core file="module/list_table_sort.html"}
{include_core file="admin/lib/footer.html"}
<!--全选js-->
